﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using XWDMes;
using MesForm.Model;
using MesForm.Common;
using System.Diagnostics;
using System.Data;
namespace MesForm
{
    public static class MesEntity
    {
        static string url = string.Empty;
        public static HotpressMesService HotpressMesService = new HotpressMesService("https://postman-echo.com/get");
        public static string _useNo = "123456";
        public static string _deviceSn = "XWDREYA";

        /// <summary>
        ///设备登录
        /// </summary>
        public static LoginCheckResult LoginCheck(LoginCheck_Model modv, out string strResponse, out string strOutMessage)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                LoginCheckResult cellResponse = JsonConvert.DeserializeObject<LoginCheckResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                _useNo = modv.userNo;
                _deviceSn = modv.deviceSn;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = modv.groupCode;
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = modv.moNumber;
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "设备登录");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 生产规格参数下发
        /// 登录成功后，每隔5分钟获取一次生产管控信息,用于检查生产电芯是否OK
        //  更新生产规格参数获取详细说明，获取规格上下限参数全部统一写入plc地址或上位机进行管控，配方类，工步信息类全部由mes下发。
        //  设备登录以及生产时五分钟获取一次mes下发参数与设备本机比对，生产时出现不一致需停机检查。

        /// </summary>
        public static GetSpecificationsResult GetSpecifications(GetSpecifications_Model modv, out string strResponse, out string strOutMessage)//Dictionary<string, object> parameters
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                GetSpecificationsResult cellResponse = JsonConvert.DeserializeObject<GetSpecificationsResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = modv.groupCode;
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = modv.moNumber;
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "生产规格参数下发");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        /// <summary>
        /// 产品进站检查
        /// </summary>
        public static InStationCheckResult InStationCheck(InStationCheck_Model modv, out string strResponse, out string strOutMessage)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                InStationCheckResult cellResponse = JsonConvert.DeserializeObject<InStationCheckResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = modv.groupCode;
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = modv.moNumber;
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "产品进站检查");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 获取测试数据
        /// </summary>
        public static GetTestDataResult GetTestData(GetTestData_Model modv, out string strResponse, out string strOutMessage)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                GetTestDataResult cellResponse = JsonConvert.DeserializeObject<GetTestDataResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = modv.groupCode;
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = modv.sn;
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "获取测试数据");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 产品数据上传过站
        /// </summary>
        public static OutStationCheckDataResult OutStationCheckData(OutStationCheckData_Model modv, out string strResponse, out string strOutMessage)//Dictionary<string, object> parameters
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                OutStationCheckDataResult cellResponse = JsonConvert.DeserializeObject<OutStationCheckDataResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = modv.groupCode;
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = modv.productSn;
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "产品数据上传过站");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                strOutMessage = $"发生异常：{ex.Message}";
                strResponse = "";
                return null;
            }
        }
        /// <summary>
        /// 获取卷芯AB面信息
        /// </summary>
        public static GetJellyrollOfABResult GetJellyrollOfAB(GetJellyrollOfAB_Model modv, out string strResponse, out string strOutMessage)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                GetJellyrollOfABResult cellResponse = JsonConvert.DeserializeObject<GetJellyrollOfABResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = "AB";
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = modv.productSn;
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "获取卷芯AB面信息");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 设备防错点检数据上传
        /// </summary>
        public static SampleDataUploadResult SampleDataUpload(SampleDataUpload_Model modv, out string strResponse, out string strOutMessage)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                SampleDataUploadResult cellResponse = JsonConvert.DeserializeObject<SampleDataUploadResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = modv.groupCode;
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = modv.productSn;
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "设备防错点检数据上传");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 设备操作权限下发
        /// </summary>
        public static DeviceOperationAuthorityResult DeviceOperationAuthority(DeviceOperationAuthority_Model modv, out string strResponse, out string strOutMessage)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                DeviceOperationAuthorityResult cellResponse = JsonConvert.DeserializeObject<DeviceOperationAuthorityResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = modv.groupCode;
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = modv.deviceSn;
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "设备操作权限下发");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// IPQC首巡检
        /// </summary>
        public static getIPQCStatusResult getIPQCStatus(getIPQCStatus_Model modv, out string strResponse, out string strOutMessage)
        {
            StackTrace stackTrace = new StackTrace();
            StackFrame stackFrame = stackTrace.GetFrame(0);
            var method = stackFrame.GetMethod();
            string methodName = method.Name;
            //bool rtnCode = false;
            try
            {
                string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startTime = DateTime.Now;
                strResponse = string.Empty;
                string strJson = JsonConvertTool.ObjectToJson(modv);
                url = HotpressMesService.GetNewUrl();
                if (url == null)
                {
                    strOutMessage = "读取Mes配置错误：URL为空";
                    return null;
                }
                strResponse = HotpressMesService.Send(url + $"/{methodName}", strJson);
                if (strResponse == null)
                {
                    strOutMessage = "发送Mes数据时发生错误：检测url是否正确";
                    return null;
                }
                getIPQCStatusResult cellResponse = JsonConvert.DeserializeObject<getIPQCStatusResult>(strResponse);
                DateTime endTime = DateTime.Now;
                TimeSpan elapsedTime = endTime - startTime;
                long elapsedMilliseconds = (long)elapsedTime.TotalMilliseconds;
                if (cellResponse == null)
                {
                    strOutMessage = "返回数据有误：检查返回数据格式";
                    return null;
                }
                #region 保存MES本地数据
                FileTool fileTool = new FileTool();
                DataRow newRow = fileTool.DtMesLog.NewRow();
                newRow["操作人员"] = _useNo;
                newRow["生产机台编号"] = _deviceSn;
                newRow["工序代码"] = "IPQC";
                newRow["mes上传地址"] = url + $"/{methodName}";
                newRow["电芯条码/托盘"] = "";
                newRow["mes上传数据"] = strJson;
                newRow["结果"] = cellResponse != null ? cellResponse.status.ToString() : "false";
                newRow["mes返回数据"] = strResponse;
                newRow["开始时间"] = startTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["结束时间"] = endTime.ToString("yyyy-MM-dd HH:mm:ss");
                newRow["测试时间(毫秒)"] = elapsedMilliseconds.ToString();
                fileTool.DtMesLog.Rows.Add(newRow);
                fileTool.SaveMesLog(newRow, methodName + "IPQC首巡检");
                #endregion
                if (cellResponse.status != null)
                {
                    strOutMessage = "";
                    return cellResponse;
                }
                strOutMessage = "返回数据有误：检查返回数据格式";
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }
        }

    }
}
